package com.nchu.student_score.controller;

import com.github.pagehelper.PageInfo;
import com.nchu.student_score.model.SubProject;
import com.nchu.student_score.model.SubScores;
import com.nchu.student_score.model.SubType;
import com.nchu.student_score.service.SubScoreService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/subScore")
public class SubScoreController {
    @Resource
    SubScoreService subScoreService;

    @RequestMapping("saveSubScores")
    public ResultVo<SubScores> saveSubScores(@RequestBody List<SubScores> scoresList){
        return subScoreService.saveSubScores(scoresList);
    }

    @RequestMapping("getSubScoreList/{currPage}")
    public PageInfo<SubScores> getSubScoreList(@RequestBody SubScores input,@PathVariable Integer currPage){
        return subScoreService.getSubScoreList(input,currPage);
    }

    @RequestMapping("selectOneProjectById")
    public ResultVo<SubProject> selectOneProjectById(@RequestBody SubProject subProject){
        return subScoreService.selectOneProjectById(subProject);
    }

    @RequestMapping("updateSubProject")
    public ResultVo<SubProject> updateSubProject(@RequestBody SubProject subProject){
        return subScoreService.updateSubProject(subProject);
    }

    @RequestMapping("getSubProject/{currPage}")
    public PageInfo<SubProject> getSubProject(@RequestBody SubProject subProject,@PathVariable Integer currPage){
        return subScoreService.getSubProjectList(subProject,currPage);
    }

    @RequestMapping("getAllSubType")
    public ResultVo<SubType> getAllSubType(){
        return subScoreService.getAllSubType();
    }

    @RequestMapping("getSubType/{currPage}")
    public PageInfo<SubType> getTypeList(@PathVariable Integer currPage){
        return subScoreService.getTypeList(currPage);
    }

    @RequestMapping("updateType")
    public ResultVo<SubType> updateType(@RequestBody SubType subType){
        return subScoreService.updateType(subType);
    }
}
